<?php
header("content-type:text/html;charset=utf-8");


require './configs/config.php';

//自动加载类
function mvc_autoload($classname)
{
	// var_dump($classname);
  if (file_exists("./models/{$classname}.class.php")) {
  	require "./models/{$classname}.class.php";
  }elseif (file_exists("./controllers/{$classname}.class.php")) {
  	require "./controllers/{$classname}.class.php";
  }else{
  	header('HTTP/1.0 404 not found');
  	header('Status: 404 not found');
  	echo "<h1>404 NOT FOUND</h1>";
  	exit;
  }
}



//导入模板引擎
require "./libs/Smarty.class.php";
spl_autoload_register('mvc_autoload');


//获取用户参数
$c = (!empty($_GET['c']))? $_GET['c']:'Index';
$a = (!empty($_GET['a']))? $_GET['a']:'index';

$classname = $c.'Controller';
$controller = new $classname();
// var_dump($controller); 
$controller->$a();

